/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import entity.Winner;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author VietTien
 */
@Stateless
public class WinnerFacade extends AbstractFacade<Winner> {
    @PersistenceContext(unitName = "BluePumpkin-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public WinnerFacade() {
        super(Winner.class);
    }

    public List<Winner> getNewestWinner() {
        Query q = em.createNamedQuery("Winner.findAll");
        q.setParameter("isDelete", false);
        q.setMaxResults(5);
        q.setFirstResult(0);
        return q.getResultList();
    }

}
